package lotus.blog.lotusblog.server.Mail;

import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Service
public class MailService {
    @Autowired
    private JavaMailSender javaMailSender;
    private String sender = "272146019@qq.com";
    public void sendSampleEmail(String message,String subject,String recipient){
        SimpleMailMessage messageContent = new SimpleMailMessage();
        messageContent.setFrom(sender);
        // 接收者
        messageContent.setTo(recipient);
        //邮件主题
        messageContent.setSubject(subject);
        // 邮件内容
        messageContent.setText(message);
        javaMailSender.send(messageContent);
    }
}
